class_name Projectile
extends Node2D

@onready var hitbox_component: HitboxComponent = %HitboxComponent

var velocity := Vector2.ZERO

func _process(delta: float) -> void:
	position += velocity * delta

func set_projectile(context_velocity: Vector2,damage: float, critical: bool, knockback_power: float, unit: Node2D) -> void:
	velocity = context_velocity
	rotation = velocity.angle()
	hitbox_component.setup(damage, critical, knockback_power, unit)

func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
	queue_free()


func _on_hitbox_component_on_hit_hurtbox(_hurtbox: HurtboxComponent) -> void:
	queue_free()
